package com.example.base.job.demo;

import com.alibaba.fastjson.JSONObject;
import com.example.base.job.Job;
import com.example.base.system.mapper.DBMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;
import java.util.Map;

@Slf4j
@Job("test")
public class JobSpringAnnotationDemo {

    @Autowired
    private DBMapper dbMapper;

    public void run(){
        String dataBaseName=dbMapper.selectDataBaseName();
        log.info("当前使用的库名:{}",dataBaseName);
        List<Map<String,String>> maps=dbMapper.selectAllTables(dataBaseName);
        for (int i = 0; i < maps.size(); i++) {
            log.info(JSONObject.toJSONString(maps.get(i)));
        }
        dbMapper.updateTableComment("sys_config","系统配置表");

        List<Map<String,Object>> mapList=dbMapper.selectTableInfo(dataBaseName,"sys_menu");
        for (int i = 0; i < mapList.size() ; i++) {
            log.info(JSONObject.toJSONString(mapList.get(i)));
        }
    }
}
